home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 116 / MacAddict 116 (Mac Power Pack)(theDISC)(April 2006).iso / Software / Graphics & Multimedia / iDive.dmg / iDive.app / Contents / Frameworks / CURLHandle.framework / Headers / CURLHandle.h next >
Text File  |  2006-01-19  |  6KB  |  149 lines

  1. //
  2. //  CURLHandle.h
  3. //
  4. //  Created by Dan Wood <dwood@karelia.com> on Fri Jun 22 2001.
  5. //  This is in the public domain, but please report any improvements back to the author.
  6. //
  7. //    The current version of CURLHandle is 1.9.
  8. //
  9.  
  10. #import <Foundation/Foundation.h>
  11. #import <curl/curl.h>
  12.  
  13.     /*" The cache has been removed "*/
  14. extern    NSString *CURLHandleCacheDeleteNotification;
  15.  
  16.     /*" The cache has been created "*/
  17. extern    NSString *CURLHandleCacheCreateNotification;
  18.  
  19.     /*" The cache has been changed "*/
  20. extern    NSString *CURLHandleCacheChangeNotification;
  21.  
  22.     /*" A handle has been created; the object is the handle itself. "*/
  23.  
  24. extern    NSString *CURLHandleCreatedNotification;
  25.  
  26.     /*" Cache of URL contents, keyed by URL "*/
  27. extern     NSMutableDictionary *sCurlCache;
  28.  
  29.     /*" Set of URLs that CURLHandle will process "*/
  30. extern    NSMutableSet        *sAcceptedURLs;
  31.  
  32.     /*" YES if CURLHandle will accept %all HTTP "*/
  33. extern    BOOL                sAcceptAllHTTP;
  34.  
  35. /*" YES if CURLHandle will allow use of a proxy server "*/
  36. extern    BOOL                sAllowsProxy;
  37.  
  38. /*" Proxy User ID:Password combo for all uses of CURL. "*/
  39. extern NSString                *sProxyUserIDAndPassword;
  40.  
  41. /*"    Callbacks from reading a chunk of data.  Since we pass "self" in as the "data pointer",
  42.     we can use that to get back into Objective C and do the work with the class.
  43. "*/
  44.  
  45. extern size_t curlBodyFunction(void *ptr, size_t size, size_t nmemb, void *inSelf);
  46. extern size_t curlHeaderFunction(void *ptr, size_t size, size_t nmemb, void *inSelf);
  47.  
  48. @interface CURLHandle : NSURLHandle
  49. {
  50.     NSThread        *mMainThread;            /*" Reference to main thread so thread can determine if it's a background thread or not "*/
  51.     CURL            *mCURL;                    /*" Pointer to the actual CURL object that does all the hard work "*/
  52.     char             mErrorBuffer[CURL_ERROR_SIZE];    /*" Buffer to hold string generated by CURL; this is then converted to an NSString. "*/
  53.     int                mResult;                /*" Result after performing a CURL operation; it is displayed as an error code in case there was no error string generated. "*/
  54.  
  55.     NSURL            *mNSURL;                /*" The instance of #NSURL that is the URL to load "*/
  56.  
  57.     NSMutableData    *mHeaderBuffer;            /*" The buffer that is filled with data from the header as the download progresses; it's appended to one line at a time. "*/
  58.  
  59.     NSString        *mHeaderString;            /*" The header buffer, converted into a string, upon demand. "*/
  60.  
  61.     NSMutableDictionary    *mStringOptions;    /*" Dictionary of keys(ints) & values (NSStrings) for performing curl_easy_setopt.  We store the options in a dictionary and then invoke #curl_easy_setopt on each option right before the #curl_easy_perform so that we can retain their memory until it is needed."*/
  62.  
  63.     NSDictionary    *mProxies;    /*" Dictionary of proxy information; it's released when the handle is deallocated since it's needed for the transfer."*/
  64.  
  65.     NSMutableDictionary        *mHTTPHeaders;    /*" Dictionary of & values (NSStrings) for additional HTTP headers.  We store the options in a dictionary and then make use of them right before the #curl_easy_perform so that we can retain their memory until it is needed."*/
  66.  
  67.     id                    mProgressIndicator;        /*" A progress indicator, to animate during foreground loads.  This will help give some indication of loading progress, though of course you're better off loading in the background. "*/
  68.  
  69.     // Backgrounding support
  70.     NSPort            *mPort;                        /*" A port for communicating between the background thread and the foreground thread. "*/
  71.  
  72.     BOOL            mAbortBackground;        /*" A flag that is set by the foreground thread and read by the background thread; it's an indicator that the user has cancelled. "*/
  73.  
  74.     FILE *mPutFile;  /*" The FILE stream if putFile: is used.  It's only saved so it can be closed after perform "*/
  75.  
  76. }
  77.  
  78. /*" CURLHandle-specific interfaces. "*/
  79.  
  80. + (void) curlGoodbye;
  81. + (void) curlHelloSignature:(NSString *) inSignature acceptAll:(BOOL)inAcceptAllHTTP;
  82. + (void)curlAcceptURL:(NSURL *)url;
  83. + (void)curlFlushEntireCache;
  84. - (CURL *) curl;
  85. - (void) setString:(NSString *)inString forKey:(CURLoption) inCurlOption;
  86. - (void) setStringOrNumberObject:(id)inString forKey:(CURLoption) inCurlOption;
  87. - (void) setURL:(NSURL *)inURL;
  88. - (NSURL *)url;
  89. - (void) setHTTPHeaders:(NSDictionary *)inDict;
  90. + (void) setProxyUserIDAndPassword:(NSString *)inString;
  91. + (void) setAllowsProxy:(BOOL) inBool;
  92. - (void) setPutFile:(NSString *)path;
  93. - (void) setPutFileOffset:(int)offset;
  94. - (NSArray *)getResponseCookies;
  95. + (NSString *) curlVersion;
  96.  
  97. /*" NSURLHandle overrides "*/
  98.  
  99. + (BOOL)canInitWithURL:(NSURL *)anURL;
  100. + (NSURLHandle *)cachedHandleForURL:(NSURL *)anURL;
  101. - (NSData *)loadInForeground;
  102. - (NSString *)curlError;
  103. - (id) initWithURL:(NSURL *)anURL cached:(BOOL)willCache;
  104. - (id)propertyForKey:(NSString *)propertyKey;
  105. - (id)propertyForKeyIfAvailable:(NSString *)propertyKey;
  106. - (void) dealloc;
  107. - (void)beginLoadInBackground;
  108. - (void)cancelLoadInBackground;
  109. - (void)endLoadInBackground;
  110.  
  111. /*" Support Methods "*/
  112.  
  113. - (size_t) curlWritePtr:(void *)inPtr size:(size_t)inSize number:(size_t)inNumber message:(int)inMessageID;
  114. - (void) curlThreadBackgroundLoad:(id)inParam;
  115. - (void) prepareAndPerformCurl;
  116. - (void)handlePortMessage:(NSPortMessage *)portMessage;
  117. - (NSString *)headerString;
  118.  
  119. @end
  120.  
  121. @interface NSDictionary ( CurlHTTPExtensions )
  122.  
  123. - (NSString *) formatForHTTP;
  124. - (NSString *) formatForHTTPUsingEncoding:(NSStringEncoding)inEncoding;
  125. - (NSString *) formatForHTTPUsingEncoding:(NSStringEncoding)inEncoding ordering:(NSArray *)inOrdering;
  126.  
  127. @end
  128.  
  129. @interface NSArray ( CurlHTTPExtensions )
  130.  
  131. - (NSDictionary *)parsedCookies;
  132.  
  133. @end
  134.  
  135. @interface NSString ( CurlHTTPExtensions )
  136.  
  137. - (NSString *) headerStatus;
  138. - (NSString *) headerHTTPVersion;
  139. - (NSString *) headerMatchingKey:(NSString *)inKey;
  140. - (NSArray *) headersMatchingKey:(NSString *)inKey;
  141. - (NSArray *) allHTTPHeaderDicts;
  142. - (NSString *) headerKey;
  143. - (NSString *) headerValue;
  144. - (NSArray *) componentsSeparatedByLineSeparators;
  145.  
  146. @end
  147.  
  148.  
  149.